load_configuration()
{
  clone_dir=$tmp_dir/clone
  frt_config_dir=$tmp_dir/frt
  git clone --bare $repo_root $clone_dir

  if [ ! -d $clone_dir ]
  then
    echo "Git repository \"$repo_root\" does not exist."
    exit 2
  fi

  cd $clone_dir

  # Export frt branch
  mkdir $frt_config_dir
  git archive -o $frt_config_dir.tar frt
  if [ ! -f $frt_config_dir.tar ]
  then
    echo "There is no \"frt\" branch in the repository \"$repo_root\""
    exit 2
  else
    tar -xf $frt_config_dir.tar -C $frt_config_dir
  fi

  # Check file exists
  if [ ! -f $frt_config_dir/frt ]
  then
    echo "I was expecting to find a \"frt\" configuration file with a branch called frt."
    exit 2
  fi
  source $frt_config_dir/frt
  load_global_configuration

  # Checkout tree
  if [ $1 ]
  then
    git archive -o $export_dir.tar $1
    if [ ! -f $export_dir.tar ]
    then
      echo "The git tree \"$1\" does not exist."
      exit 2
    else
      tar -xf $export_dir.tar -C $export_dir
    fi
  fi
}

prepare_script()
{
  prepare_script=$frt_config_dir/prepare.frt
}

prepare_usage()
{
  echo "USAGE: $0 prepare -V git [repository] [tree_ish]"
  exit 1
}

